home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / minix / update~4.z / update~4 / lib_stdio_ftell.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-06  |  603 b   |  32 lines

  1. /*                f t e l l
  2.  *
  3.  * Report the position within a stream. The function returns
  4.  * the offset of the current byte relative to the beginning
  5.  * of the file associated with the named stream.
  6.  *
  7.  * Patchlevel 1.0
  8.  *
  9.  * Edit History:
  10.  */
  11.  
  12. #include "stdiolib.h"
  13.  
  14. /*LINTLIBRARY*/
  15.  
  16. long ftell(fp)
  17.  
  18. FILE *fp;                /* stream */
  19.  
  20. {
  21.   long pos;                /* current location */
  22.   long tell();                /* location within file */
  23.  
  24.   if ((pos = tell(fp->_file)) == -1L || TESTFLAG(fp, _IONBF))
  25.     return pos;
  26.  
  27.   if (TESTFLAG(fp, _IOWRITE))
  28.     return pos + (fp->_ptr - fp->_base);
  29.   else
  30.     return pos - (fp->_end - fp->_ptr);
  31. }
  32.